/**
*      author: Y_Yao
*      created: 2025-02-22 20:22:18
**/

#include<bits/stdc++.h>

#define int LL
using namespace std;
using LL = long long;
const LL LLINF = 1e18;
const int INF = 0x3f3f3f3f;
string s;
stack<char> st;
unordered_map<char,char> mp;

void solve()
{
    cin >> s;
    mp[']'] = '[';
    mp[')'] = '(';
    mp['>'] = '<';

    for(int i = 0;i < s.size();i++)
    {
        if(s[i] == '[' || s[i] == '<' || s[i] == '(')
        {
            st.push(s[i]);
        }
        else
        {
            if(st.empty())
            {
                cout << "No" << endl;
                return;
            }
            char top = st.top();
            if(top != mp[s[i]])
            {
                cout << "No" << endl;
                return;
            }
            st.pop();
        }
    }
    if(st.empty()) 
    {
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int t = 1;
    //cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}
